<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
<?=$page_title?>
</title>
<base href="<?=base_url()?>" />
<script type="text/javascript" src="js/jquery.js"></script>
<!--time-->
<link rel="stylesheet" href="themes/base/jquery.ui.all.css">
<script src="js/ui/jquery.ui.core.js"></script>
<script src="js/ui/jquery.ui.widget.js"></script>
<script src="js/ui/jquery.ui.datepicker.js"></script>
<link rel="stylesheet" href="css/demos.css">

<link href="css/clientpublic.css" rel="stylesheet" type="text/css">


<script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="js/fancybox/jquery.easing-1.3.pack.js"></script>
<script type="text/javascript" src="js/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="js/fancybox/jquery.fancybox-1.3.4.css" />
<link rel="stylesheet" type="text/css" href="css/jia.css" />
<script language='javascript' src='js/suggest.js'></script>
<link href="js/suggest.css" rel="stylesheet" type="text/css">
<!--共享弹出框-->
<link href="styles/core.css" type="text/css" rel="stylesheet"/>
<script src="scripts/popup_layer.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
	$(document).ready(function() {
		jQuery.ajaxSetup ({cache:false}); /*让ajax不调用浏览的缓存*/
		$(".various1").fancybox({
		'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack',
		'hideOnOverlayClick' : false,
		'onComplete'	: function() {
				var suggest = new GoogleSuggest("myform", "customer_name", 0);
			}
		});
	});
</script>

</head>
<body>
	<div id="Holder">
		<div id="MainPage">
			<!---------头部------------->
			<?php include('top.php')?>
			<div id="Subnav">
				<ul>
                
					<li class="active show"></li>
				
                </ul>
			</div>
			<!---------中间部分------------->
			<div id="MainBody">
				<div class="welcome_me">
					Welcome to <span>CRM</span>
			  </div>
  				<table  id="ContentTable" class="jia_data-box">
                	<!---第一行--->
					<tr class="first_line">
                    	<td width="25">&nbsp;</td>
                    	<!---第一行 第1列--->
                    	<td class="first_line1">
                        	<table>
                            	<tr>
                                	<td width="7" class="first_line1_l"></td>
                                    <td valign="top" class="first_line1_m">
                                    	<h3>代办任务<a href="<?=base_url()?>index.php/schedule/display">&gt;&gt;more</a></h3>
                                        <div>
                                        	<h1 style="color:#d7000f;">一周内任务</h1>
                                        	<ul>
                                            	<?php foreach($after_seven_days_schedules as $after_seven_days_schedule):?>
												<?php 
                                                date_default_timezone_set('PRC');
                                                $now=date('Y-m-d', strtotime('now'));
                                                $date='今天';
                                                $datatime = strtotime($after_seven_days_schedule->execution_time);
                                                $schedule_date = date( "Y-m-d",$datatime);
                                                if($schedule_date != $now){
                                                    $date = $schedule_date;
                                                }
                                                ?>
                                            	<li><a class="various1" href="<?=base_url()?>index.php/schedule/get_schedule/<?= $after_seven_days_schedule->schedule_id?>"><?= $after_seven_days_schedule->subject?></a>
                                 <span><?= $date?></span></li>
                                                <?php endforeach;?>
                                            </ul>
                                            <h1>超期任务</h1>
                                            <ul>
                                            	<?php foreach($extended_schedules as $extended_schedule):?>
												<?php 
                                                $datatime = strtotime($extended_schedule->execution_time);
                                                $schedule_date = date( "Y-m-d",$datatime);?>
                                            	<li><a class="various1" href="<?=base_url()?>index.php/schedule/get_schedule/<?= $extended_schedule->schedule_id?>"><?= $extended_schedule->subject?></a><span><?= $schedule_date?></span></li>
                                                <?php endforeach;?>
                                                
                                            </ul>
                                        </div>
                                    </td>
                                    <td width="10" class="first_line1_r"></td>
                              </tr>
                            </table>
                        </td>
                        <td width="25">&nbsp;</td>
                        <!---第一行 第2列--->
                        <td class="first_line2">
                        	<table>
                            	<tr>
                                	<td width="7" class="first_line2_l"></td>
                                    <td valign="top" class="first_line2_m">
                                    	<h3>应收款项（30天内或已经过期）<a href="<?=base_url()?>index.php/payment_plan/index">&gt;&gt;more</a></h3>
                                        <div>
                                        	<ul>
                                            	<!-- 今天之前 -->
                                            	<?php foreach($before_receivables as $before_receivable):?> <!-- 今天之前 -->
												<?php 
                                                  $datatime = strtotime($before_receivable->payment_time);
                                                  $payment_time = date( "Y-m-d",$datatime);
                                                  $back = '已回';
                                                  $color='green';
                                                  if(!$receivable->back){
                                                    $back = '未回';
                                                    $color='red';
                                                  }
                                                ?>
                                            	<li><a class="various1" href="<?=base_url()?>index.php/payment_plan/find/<?= $before_receivable->id?>" > 
                                	￥<?= $before_receivable->money?> 期次：<?= $before_receivable->stages?>期</a><span><?= $before_receivable->customer_name?></span>
                                <span><?= $payment_time?></span><span style="color:<?php echo $color;?>;"><?= $back?></span></li>
                                                <?php endforeach;?>
                                                <!-- 未来30天 -->
                                                <?php foreach($receivables as $receivable):?>	<!-- 未来30天 -->
												<?php 
                                                  $datatime = strtotime($receivable->payment_time);
                                                  $payment_time = date( "Y-m-d",$datatime);
                                                  $back = '已回';
                                                  $color='green';
                                                  if(!$receivable->back){
                                                    $back = '未回';
                                                    $color='red';
                                                  }
                                                ?>
                                                <li><a class="various1" href="<?=base_url()?>index.php/payment_plan/find/<?= $receivable->id?>"> 
                                	￥<?= $receivable->money?> 期次：<?= $receivable->stages?>期</a><span><?= $receivable->customer_name?></span>
                                <span><?= $payment_time?></span><span style="color:<?php echo $color;?>;"><?= $back?></span></li>
                                                <?php endforeach;?>
                                            </ul>
                                        </div>
                                    </td>
                                    <td width="10" class="first_line2_r"></td>
                              </tr>
                            </table>
                        </td>
                        <td width="25">&nbsp;</td>
                        <!---第一行 第3列--->
                        <td class="first_line3">
                        	<table>
                            	<tr>
                                	<td width="7" class="first_line3_l"></td>
                                    <td valign="top" class="first_line3_m">
                                    	<h3>新客户<a href="<?=base_url()?>index.php/customer/index">&gt;&gt;more</a></h3>
                                        <div>
                                        	<ul>
                                            	<?php foreach($customers as $customer):?>
												<?php 
                                                 /*$parent_name='';
                                                  $parent_id =$customer->parent_id;
                                                  if($parent_id != 0){
                                                    $sql="SELECT customer_name as parent_name FROM customer where id = $parent_id ";
                                                    $query = $this->db->query($sql);
                                                    $row = $query->row_array();
                                                    $parent_name=$row['parent_name'];
                                                  }else{
                                                    $parent_name = '顶级客户';
                                                  }*/
                                                ?>
                                            	<li><a class="various1" href="<?=base_url()?>index.php/customer/console_find_customer/<?= $customer->id?>"><?= $customer->customer_name?></a><span>所属区域:<?= $customer->district?></span></li>
                                                <?php endforeach;?>
                                            </ul>
                                        </div>
                                    </td>
                                    <td width="10" class="first_line3_r"></td>
                              </tr>
                            </table>
                        </td>
                        <td width="25">&nbsp;</td>
                    </tr>
                    
                    <!---第二行 --->
                    <tr height="30"><td>&nbsp;</td></tr>
                    
                    <!---第三行 --->
                    <tr class="second_line">
                    	  <!---第二行 第1列--->
                          <td width="25">&nbsp;</td>
                          <td class="second_line1">
                          	<table>
                            	<tr>
                                	<td width="7" class="second_line1_l"></td>
                                    <td valign="top" class="second_line1_m">
                                    	<h3>新销售机会<a href="<?=base_url()?>index.php/opportunity/index">&gt;&gt;more</a></h3>
                                        <div>
                                        	<ul>
                                            	<?php foreach($opportunitys as $opportunity):?>
                                            	<?php 
                                            		$datatime = strtotime($opportunity->create_time);
                                            		$create_time = date( "Y-m-d",$datatime);
                                            	?>
                                            	<li><a class="various1" href="<?=base_url()?>index.php/opportunity/console_find_opportunity/<?= $opportunity->id?>"><?= $opportunity->subject?></a><span><?= $create_time?></span></li>
                                                <?php endforeach;?>
                                            </ul>
                                        </div>
                                    </td>
                                    <td width="10" class="second_line1_r"></td>
                              </tr>
                            </table>
                          </td>
                          <td width="25">&nbsp;</td>
                          <!---第二行 第2列--->
                          <td class="second_line2">
                          	<table>
                            	<tr>
                                	<td width="7" class="second_line2_l"></td>
                                    <td valign="top" class="second_line2_m">
                                    	<h3>新联系人<a href="<?=base_url()?>index.php/contacter/index">&gt;&gt;more</a></h3>
                                        <div>
                                        	<ul>
                                            	<?php foreach($contacters as $contacter):?>
												 <?php
                                                    $gender = '女';
                                                    if ($contacter->sex) {
                                                        $gender = '男';
                                                    }
                                                    ?>
                                                    <?php
                                                        $fenlei = '';
                                                        switch ($contacter->classify->classify) {
                                                            case 5 :
                                                                $fenlei = '特别重要' ;
                                                                break;
                                                            case 4 :
                                                               $fenlei  = '重要' ;
                                                                break;
                                                            case 3 :
                                                                $fenlei = '普通' ;
                                                                break;
                                                            case 2 :
                                                               $fenlei  = '不重要' ;
                                                                break;
                                                            default :
                                                               $fenlei  = '失效' ;
                                                        }
                                                    ?>
                                            	<li><a class="various1" href="<?=base_url()?>index.php/contacter/console_find_contacter/<?= $contacter->id?>">
                                <?= $contacter->name?></a><span>性别：<?= $gender?></span><span><?= $contacter->mobile_phone?></span></li>
                                                <?php endforeach;?>
                                            </ul>
                                        </div>
                                    </td>
                                    <td width="10" class="second_line2_r"></td>
                              </tr>
                            </table>
                          </td>
                          <td width="25">&nbsp;</td>
                          <!---第二行 第3列--->
                          <td class="second_line3">
                          	<table>
                            	<tr>
                                	<td width="7" class="second_line3_l"></td>
                                    <td valign="top" class="second_line3_m">
                                    	<h3>新合同/订单<a href="<?=base_url()?>index.php/contract/index">&gt;&gt;more</a></h3>
                                        <div>
                                        	<ul>
                                            	<?php foreach($contracts as $contract):?>
                                            	<li><a class="various1" href="<?=base_url()?>index.php/contract/find/<?= $contract->contract_id?>"><?= $contract->subject?></a><span>￥<?= $contract->total_amount?>万元</span></li>
                                                <?php endforeach;?>
                                                
                                            </ul>
                                        </div>
                                    </td>
                                    <td width="10" class="second_line3_r"></td>
                              </tr>
                            </table>
                          </td>
                          <td width="25">&nbsp;</td>
                    </tr>
              </table>
		  </div>
			<!---------结尾------------->
			<?php include('footer.php')?>
		</div>
	</div>
	<input type="hidden" id="baseurl" value="<?=base_url()?>"/>
</body>
</html>